import java.util.StringTokenizer;

class P10141 {

   public static void main(String[] args) {
       try {
       String line = readLn();
       int counter = 1;
       while(!line.equals("0 0")) {
           System.out.println("RFP #" + counter);
           counter++;

           StringTokenizer st = new StringTokenizer(line);
           int n = Integer.parseInt(st.nextToken());
           int p = Integer.parseInt(st.nextToken());

           for (int k = 0; k < n; k++) {
               readLn();
           }

//                                 number_of_requirements_met
//            compliance = --------------------------
//                           number_of_requirements

           int compliance = -1;
           String answer = null;
           double price = Double.MAX_VALUE;

           for (int k = 0; k < p; k++) {
               String brand = readLn();
               StringTokenizer st1 = new StringTokenizer(readLn());
               double currentPrice = new Double(st1.nextToken()).doubleValue();
               int met = Integer.parseInt(st1.nextToken());
               if (compliance < met) {
                   compliance = met;
                   answer = brand;
                   price = currentPrice;
               } else if (compliance == met) {
                   if (price > currentPrice) {
                       compliance = met;
                       answer = brand;
                       price = currentPrice;
                   }
               }
               for (int i = 0; i < met; i++) {
                   readLn();
               }
           }

           System.out.println(answer);
           line = readLn();
           if (!line.equals("0 0"))
        	   System.out.println();
       }
       } catch (Exception e) {
           while (true) {

           }
       }
   }

   static String readLn() {
       String newLine = System.getProperty("line.separator");
       StringBuffer buffer = new StringBuffer();
       int car = -1;
       try {
           car = System.in.read();
           while ((car > 0) && (car != newLine.charAt(0))) {
               buffer.append((char)car);
               car = System.in.read();
           }
           if (car == newLine.charAt(0))
           System.in.skip(newLine.length() - 1);
       } catch (java.io.IOException e) { return (null);}
       if ((car < 0) && (buffer.length() == 0)) return (null);
       return (buffer.toString()).trim();
   }

}
